<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/derek-tags" prefix="dk" %>
<dk:WarPath/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
  <head>
    <title>修改登陆密码</title>
	<link rel=stylesheet type=text/css href="${_WarPath }/css/global.css"/>
	<script src="${_WarPath }/js/jquery-1.4.js" type="text/javascript"></script>
	
	<script type="text/javascript">
		var requestUrl = "/xinlu/user/modifyUserPwdAction.html";
		$(function(){
			$("#modifyPwd").bind("click", function(){
				
				if(checkForms()){
					$.ajax({
				
						url : requestUrl,
						type : "post",
						dataType : "text",
						async:false,
						cache:false,
						data : {
							
							doAction : "modifyUserNewPwd",
							pageId : "modifyUserPwd",
							modifyUsername : $("#username").text(),
							newPwd : $("#pwd1").val()
							
						},
						error : function(data){
							
							alert('网络发生异常,请重试....');
						},
						success : function(data){
							
							if(data == 'fail'){
							
								alert('你输入的动态密码不正确,请查看安全邮箱，或者联系客服！');								
							}else{
								
								alert('密码修改成功,您可以正常登陆了！');
								window.location.href = "/xinlu/jsp/frame/index.jsp";
							}
						}
						
					});
				}
				
			});
			
			$("#sendEmailAgin").bind("click", function(){
				
					$.ajax({
						url : requestUrl,
						type : "post",
						dataType : "text",
						async:false,
						cache:false,
						data : {
							
							doAction : "sendEmailAgin",
							pageId : "modifyUserPwd"
							
						},
						error : function(data){
							
							alert('网络发生异常,请重试....');
						},
						success : function(data){
							
							if(data == 'fail'){
								alert('您太长时间没操作,请登录首页后，再修改密码。');
								window.location.href = "/xinlu/jsp/frame/index.jsp";
							}else{
								alert('邮件发送成功,请注意查收!');
							}
						}
						
					});
				
			});
		});
		
		
		function checkForms(){
			
			if($.trim($("#dymicPwd").val()) == ''){
				
				alert('动态密码不能为空,请输入用户名!');
				return false;
			}
			
			if($.trim($("#dymicPwd").val()) == ''){
				
				alert('动态密码不能为空,请输入动态密码!');
				return false;
			}
			
			if($.trim($("#pwd1").val()) == '' || $.trim($("#pwd2").val() == '')){
				
				alert('密码码不能为空,请输入正确的密码!');
				return false;
			}
			
			if($.trim($("#pwd1").val()) != $.trim($("#pwd2").val())){
				
				alert('两次输入的密码不一样，请重新输入!');
				return false;
			}
			
			var dymicPwdRight = true;
			$.ajax({
				
				url : requestUrl,
				type : "post",
				dataType : "text",
				async:false,
				cache:false,
				data : {
					
					doAction : "checkDymaicPwd",
					pageId : "modifyUserPwd",
					oldPwd : $("#dymicPwd").val(),
					modifyUsername : $("#username").text()
				},
				error : function(data){
					
					alert('网络发生异常,请重试....');
				},
				success : function(data){
					
					if(data == 'fail'){
						alert('你输入的动态密码不正确,请查看安全邮箱，或者联系客服！');
						dymicPwdRight = false;
					}
				}
				
			});
			
			if(!dymicPwdRight){
				
				//alert('动态密码不正确,请重新输入！');
				return false;
			}
			
			return true;
		}
		
	</script>
  </head>
  
  <body>
    
 	<div class="main_b">
    <div class="buy">
        <div class="nav_t">
            <b class="lt"></b>
            <b class="rt"></b>
            <div class="tname">
                <b class="lt"></b>
                <b class="rt"></b>
                <div>安全邮箱</div>
            </div>
        </div>
	        <div class="info_body">
				<div class="info">
			
					<table id="tablehovered" class="tableborder" border="0" cellSpacing="1" cellPadding="1" align="center">
						<tr>
							<th colSpan="2">
							提示：登陆密码找回
							</th>
						</tr>
						<tr><td class="pe_right" colSpan="2">动态密码已经发到：***，请登陆您的安全邮箱查收(如 收件箱 里未看到，请注意查看 垃圾箱)。然后用动态密码在这里设置新密码。</td></tr>
						<tr><th colSpan="2">操作：</th></tr>
		
						<form method="post" name="form1" action="">
		
						<tr><td class="tablerow2  hovered" colSpan="2" align="center">获得动态密码后，请通过下面的方式设置新密码！</td></tr>
						<tr><td class="tablerow1  hovered" align="center">用户名：</td><td id="username" class="tablerow1  hovered"><s:property value='#session.user.username' /></td></tr>
						<tr><td class="tablerow2  hovered" align="center">动态密码：</td><td class="tablerow2  hovered"><input name="pass0" id="dymicPwd" value="" size="30" type="text" /></td></tr>
						
						<tr><td class="tablerow1  hovered" align="center">新密码：</td><td class="tablerow1  hovered"><input name="pass1" id="pwd1" value="" size="30" type="password" /></td></tr>
						<tr><td class="tablerow2  hovered" align="center">确认密码：</td><td class="tablerow2  hovered"><input name="pass2" id="pwd2" value="" size="30" type="password" /></td></tr>
						
						<tr><td class="tablerow1  hovered" colSpan="2" align="center"><a href="#;" id="sendEmailAgin">重发邮件</a> <input name="xg" value=" 提 交 " type="button" id="modifyPwd" /> </td></tr>
		
						</form>
		
		
					</table>
			</div>
        	<div class="clb"></div>
		</div>
    </div>
</div>
    
  </body>
</html>
